
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
final GlobalKey<FluViewState> fluViewStateKey = GlobalKey();
class FluView extends StatefulWidget {
  const FluView({super.key});

  @override
  State<FluView> createState() => FluViewState();
}

class FluViewState extends State<FluView> {
  final MethodChannel methodChannel = MethodChannel('com.lx.FluView.methodChannel');
  @override
  void initState() {
    methodChannel.setMethodCallHandler((call)async{

    });
    super.initState();
  }

  addNum(num){
    print('--->addNum=$num');
    methodChannel.invokeMethod('addNum',{'num': num});
  }
  @override
  Widget build(BuildContext context) {
    
    if(Platform.isAndroid){
      return AndroidView(
          viewType: "com.lx.fluview",
        creationParams: {'num':-1},
        creationParamsCodec: StandardMessageCodec(),
      );
    }else if(Platform.isIOS){
      return UiKitView(
        viewType: "com.lx.fluview",
        creationParams: {'num':-1},
        creationParamsCodec: JSONMessageCodec(),
      );
    }else{
      return Container();
    }
  }
}
